home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1 / Nebula One.iso / Communications / pcomm / Source / s_axfer.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-06-12  |  3.7 KB  |  127 lines

  1. /*
  2.  * Display the ASCII transfer setup, query for changes.  A non-zero return
  3.  * code means something was changed.
  4.  */
  5.  
  6. #include <stdio.h>
  7. #include <curses.h>
  8. #include "config.h"
  9. #include "misc.h"
  10. #include "param.h"
  11.  
  12. int
  13. axfer_setup()
  14. {
  15.     extern char *v_yes[];
  16.     WINDOW *x_win, *newwin();
  17.     int i, ret_code, num;
  18.     char *ans, *menu_prompt(), *str_rep();
  19.     static char *v_cr[4] = {"NONE", "STRIP", "ADD LF", NULL};
  20.     static char *v_lf[4] = {"NONE", "STRIP", "ADD CR", NULL};
  21.     static char *v_delay[4] = {"0", "100", "150", NULL};
  22.  
  23.     x_win = newwin(23, 80, 0, 0);
  24.  
  25.     horizontal(x_win, 0, 0, 28);
  26.     mvwattrstr(x_win, 0, 29, A_BOLD, "ASCII Transfer Setup");
  27.     horizontal(x_win, 0, 50, 29);
  28.     mvwaddstr(x_win, 3, 33, "ASCII UPLOAD");
  29.     mvwprintw(x_win, 5, 22, "1) Echo locally ........... %s", param->lecho);
  30.     mvwprintw(x_win, 6, 22, "2) Expand blank lines ..... %s", param->expand);
  31.     mvwprintw(x_win, 7, 22, "3) CR delay (ms) .......... %d", param->cr_delay);
  32.     mvwprintw(x_win, 8, 22, "4) Pace the output ........ %s", param->pace);
  33.     mvwprintw(x_win, 9, 22, "5) CR translation ......... %s", param->cr_up);
  34.     mvwprintw(x_win, 10, 22, "6) LF translation ......... %s", param->lf_up);
  35.     mvwaddstr(x_win, 12, 32, "ASCII DOWNLOAD");
  36.     mvwprintw(x_win, 14, 22, "7) Transfer timeout (sec) . %d", param->timer);
  37.     mvwprintw(x_win, 15, 22, "8) CR translation ......... %s", param->cr_dn);
  38.     mvwprintw(x_win, 16, 22, "9) LF translation ......... %s", param->lf_dn);
  39.     horizontal(x_win, 19, 0, 80);
  40.     mvwattrstr(x_win, 20, 0, A_BOLD, "OPTION ==> ");
  41.     mvwaddstr(x_win, 20, 58, "Press <ESC> to return");
  42.     wmove(x_win, 20, 12);
  43.     touchwin(x_win);
  44.     wrefresh(x_win);
  45.                     /* get the option number */
  46.     ret_code = 0;
  47.     while ((i = get_num(x_win, 1)) != -1) {
  48.         switch (i) {
  49.             case 1:
  50.                 if ((ans = menu_prompt(x_win, 5, 50, "Echo locally", v_yes)) != NULL) {
  51.                     param->lecho = str_rep(param->lecho, ans);
  52.                     ret_code++;
  53.                 }
  54.                 break;
  55.             case 2:
  56.                 if ((ans = menu_prompt(x_win, 6, 50, "Expand blank lines", v_yes)) != NULL) {
  57.                     param->expand = str_rep(param->expand, ans);
  58.                     ret_code++;
  59.                 }
  60.                 break;
  61.             case 3:
  62.                 if ((ans = menu_prompt(x_win, 7, 50, "CR delay (ms)", v_delay)) != NULL) {
  63.                     param->cr_delay = atoi(ans);
  64.                     ret_code++;
  65.                 }
  66.                 break;
  67.             case 4:
  68.                 if ((ans = menu_prompt(x_win, 8, 50, "Pace the output", v_yes)) != NULL) {
  69.                     param->pace = str_rep(param->pace, ans);
  70.                     ret_code++;
  71.                 }
  72.                 break;
  73.             case 5:
  74.                 if ((ans = menu_prompt(x_win, 9, 50, "CR translation (upload)", v_cr)) != NULL) {
  75.                     param->cr_up = str_rep(param->cr_up, ans);
  76.                     ret_code++;
  77.                 }
  78.                 break;
  79.             case 6:
  80.                 if ((ans = menu_prompt(x_win, 10, 50, "LF translation (upload)", v_lf)) != NULL) {
  81.                     param->lf_up = str_rep(param->lf_up, ans);
  82.                     ret_code++;
  83.                 }
  84.                 break;
  85.             case 7:
  86.                 if ((num = num_prompt(x_win, 14, 50, "Transfer timeout", "(in seconds)")) != -1) {
  87.                     if (num > MAX_TIMER || num < MIN_TIMER) {
  88.                         beep();
  89.                     /* some reasonable range of values */
  90.                         if (num < MIN_TIMER)
  91.                             num = MIN_TIMER;
  92.                         else
  93.                             num = MAX_TIMER;
  94.                         mvwaddstr(x_win, 14, 50, "   ");
  95.                         wrefresh(x_win);
  96.                         mvwattrnum(x_win, 14, 50, A_BOLD, num);
  97.                         wrefresh(x_win);
  98.                     }
  99.                     param->timer = num;
  100.                     ret_code++;
  101.                 }
  102.                 break;
  103.             case 8:
  104.                 if ((ans = menu_prompt(x_win, 15, 50, "CR translation (download)", v_cr)) != NULL) {
  105.                     param->cr_dn = str_rep(param->cr_dn, ans);
  106.                     ret_code++;
  107.                 }
  108.                 break;
  109.             case 9:
  110.                 if ((ans = menu_prompt(x_win, 16, 50, "LF translation (download)", v_lf)) != NULL) {
  111.                     param->lf_dn = str_rep(param->lf_dn, ans);
  112.                     ret_code++;
  113.                 }
  114.                 break;
  115.             default:
  116.                 beep();
  117.         }
  118.         mvwaddch(x_win, 20, 12, (chtype) ' ');
  119.         clear_line(x_win, 21, 0, FALSE);
  120.         clear_line(x_win, 22, 0, FALSE);
  121.         wmove(x_win, 20, 12);
  122.         wrefresh(x_win);
  123.     }
  124.     delwin(x_win);
  125.     return(ret_code);
  126. }
  127.